<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单击事件</title>
    <script>

    </script>
    <style>
        .bg{
            background-color: red;
            width:200px;
            height:200px;
        }
    </style>
</head>
<body>
   <div class="bg" id="bg"></div> 
</body>
<script>
    //获取ID值是特定值夫人网页元素在js中的表示方式
   var bg = document.getElementById("bg");
   bg.onclick = function(){
       alert("小胖被点击了");
   }
   //当鼠标移动到div上市，在控制台打印输出
   //当鼠标箭头移上了div

   bg.onmouseover = function(){
       console.log("小胖nb");
   }
   bg.onmouseout = function(){
       console.log("小胖nb");
   }
</script>
</html>